<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');
class Block_model extends AppModel{
    var $_tablename = BLOCK;
    var $_primary_key = BLOCK_BLOCK_ID;
    var $_mapping = array(
                           array('id' => BLOCK_BLOCK_ID),
                           array('admin_id' => BLOCK_FRANCHISE_ID),
                           array('block_type' => BLOCK_BLOCK_TYPE),
                           array('name' => BLOCK_NAME),
                           array('function' => BLOCK_FUNCTION_NAME),
                           array('content' => BLOCK_CONTENT),
                           array('obj_id' => BLOCK_OBJ_ID),
                        );
    function Block_model($id=NULL){
        parent::AppModel($id);
        $CI = &get_instance();
        $CI->load->module_define('configurations');
    }
    
    function get_blocks($page_id){
        $cond = array(CELL_LINK_FRANCHISE_ID=>$this->admin_id,
                      CELL_LINK_PAGE_ID=>$page_id,);
        $this->db->where($cond);
        $this->db->orderby(CELL_LINK_COL_ID);
        $this->db->orderby(CELL_LINK_ORDER_ID);
        return $this->db->get(CELL_LINK)->result();
    }
    
    function get_block_by_function_name($func_name){
        $cond = array(BLOCK_FRANCHISE_ID=>$this->admin_id,
                      BLOCK_FUNCTION_NAME=>$func_name,);
        $this->db->where($cond);
        return $this->db->get($this->_tablename)->row();
    }
}
?>